<fieldset>
  <legend>Categories</legend>  
  <div class="categories_list">
    <% cat_array = Array.new %>
    <% Category.list.each { |c| 
        cat_array << c.name if c && !c.children? } if Category.list %>
    <% cat_array = cat_array.inspect %>

    <%= link_to '[Expand all]', '#', 
        :onclick => "categoryExpandAll(#{cat_array});" %> |
    <%= link_to '[Hide all]', '#', 
        :onclick => "categoryContractAll(#{cat_array});" %>   
    
    <ul>
      <%= render :partial => 'layouts/sub_category_div',
          :collection => Category.root_categories, :as => :cat %>
    </ul>
  </div>
</fieldset>